Skip to content

Fix command line parameter parsing to support values containing commas#5335

Open
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5329-comma-in-parameters
Open

Fix command line parameter parsing to support values containing commas#5335
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5329-comma-in-parameters

Conversation

@nikitanagar08
Copy link

Fixes #5329

Problem:
The parser split on ALL commas, breaking when values contained commas (e.g., "items=apple,banana,orange" would parse "banana" as a type name).

Solution:
Added intelligent parsing that checks if a token looks like a class name before treating it as type. If not, all commas are treated as part of the value.

Tests:

  • Added tests for values with commas
  • All existing tests pass (24 tests)

The parameter format is: key=value,type,identifying
Previously, the parser split on ALL commas, which broke when values
contained commas. For example, "items=apple,banana,orange" would be
incorrectly parsed, treating "banana" as a type name.

This commit adds intelligent parsing that:
1. Checks if the second-to-last token looks like a class name
2. If yes, treats everything before it as the value (which may contain commas)
3. If no, treats the entire string as the value with commas included

The heuristic "looks like a class name" checks for:
- Fully qualified class names (contain dots like java.lang.String)
- Primitive types (int, long, double, etc.)

This allows values containing commas to work correctly while
maintaining backward compatibility with existing parameter formats.

Fixes spring-projects#5329

Signed-off-by: Nikita Nagar <permanayan84@gmail.com>
@nikitanagar08 nikitanagar08 force-pushed the fix-5329-comma-in-parameters branch from 04dd7ad to 2ca86ae Compare March 12, 2026 05:00
@nikitanagar08
Copy link
Author

This PR fixes #5329 - Command line parameter values containing commas are now supported. The fix adds intelligent parsing that distinguishes between commas that are separators vs commas that are part of the value. All 797 core tests pass with backward compatibility maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comma no more supported in command line parameter value since v5

1 participant